/**
 */
package tpi.obj3.planificador.planificador.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import tpi.obj3.planificador.planificador.Materia;
import tpi.obj3.planificador.planificador.PlanificadorPackage;
import tpi.obj3.planificador.planificador.Recurso;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Materia</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link tpi.obj3.planificador.planificador.impl.MateriaImpl#getName <em>Name</em>}</li>
 *   <li>{@link tpi.obj3.planificador.planificador.impl.MateriaImpl#getHoras <em>Horas</em>}</li>
 *   <li>{@link tpi.obj3.planificador.planificador.impl.MateriaImpl#getDias <em>Dias</em>}</li>
 *   <li>{@link tpi.obj3.planificador.planificador.impl.MateriaImpl#getRequerimientos <em>Requerimientos</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MateriaImpl extends ElementoImpl implements Materia
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The default value of the '{@link #getHoras() <em>Horas</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHoras()
   * @generated
   * @ordered
   */
  protected static final int HORAS_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getHoras() <em>Horas</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHoras()
   * @generated
   * @ordered
   */
  protected int horas = HORAS_EDEFAULT;

  /**
   * The default value of the '{@link #getDias() <em>Dias</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDias()
   * @generated
   * @ordered
   */
  protected static final int DIAS_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getDias() <em>Dias</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDias()
   * @generated
   * @ordered
   */
  protected int dias = DIAS_EDEFAULT;

  /**
   * The cached value of the '{@link #getRequerimientos() <em>Requerimientos</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRequerimientos()
   * @generated
   * @ordered
   */
  protected EList<Recurso> requerimientos;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected MateriaImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return PlanificadorPackage.Literals.MATERIA;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PlanificadorPackage.MATERIA__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getHoras()
  {
    return horas;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHoras(int newHoras)
  {
    int oldHoras = horas;
    horas = newHoras;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PlanificadorPackage.MATERIA__HORAS, oldHoras, horas));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getDias()
  {
    return dias;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDias(int newDias)
  {
    int oldDias = dias;
    dias = newDias;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PlanificadorPackage.MATERIA__DIAS, oldDias, dias));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Recurso> getRequerimientos()
  {
    if (requerimientos == null)
    {
      requerimientos = new EObjectResolvingEList<Recurso>(Recurso.class, this, PlanificadorPackage.MATERIA__REQUERIMIENTOS);
    }
    return requerimientos;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case PlanificadorPackage.MATERIA__NAME:
        return getName();
      case PlanificadorPackage.MATERIA__HORAS:
        return getHoras();
      case PlanificadorPackage.MATERIA__DIAS:
        return getDias();
      case PlanificadorPackage.MATERIA__REQUERIMIENTOS:
        return getRequerimientos();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case PlanificadorPackage.MATERIA__NAME:
        setName((String)newValue);
        return;
      case PlanificadorPackage.MATERIA__HORAS:
        setHoras((Integer)newValue);
        return;
      case PlanificadorPackage.MATERIA__DIAS:
        setDias((Integer)newValue);
        return;
      case PlanificadorPackage.MATERIA__REQUERIMIENTOS:
        getRequerimientos().clear();
        getRequerimientos().addAll((Collection<? extends Recurso>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case PlanificadorPackage.MATERIA__NAME:
        setName(NAME_EDEFAULT);
        return;
      case PlanificadorPackage.MATERIA__HORAS:
        setHoras(HORAS_EDEFAULT);
        return;
      case PlanificadorPackage.MATERIA__DIAS:
        setDias(DIAS_EDEFAULT);
        return;
      case PlanificadorPackage.MATERIA__REQUERIMIENTOS:
        getRequerimientos().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case PlanificadorPackage.MATERIA__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case PlanificadorPackage.MATERIA__HORAS:
        return horas != HORAS_EDEFAULT;
      case PlanificadorPackage.MATERIA__DIAS:
        return dias != DIAS_EDEFAULT;
      case PlanificadorPackage.MATERIA__REQUERIMIENTOS:
        return requerimientos != null && !requerimientos.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", horas: ");
    result.append(horas);
    result.append(", dias: ");
    result.append(dias);
    result.append(')');
    return result.toString();
  }

} //MateriaImpl
